<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Carbon;

class Setting extends  Model
{
    use HasFactory;
    use SoftDeletes;

    static $unguarded = true;

    protected $table = 'setting';

    /**
     * 根据key获取值
     *
     * @param $key
     * @return array|Builder
     */
    public static function getDataByKey($key){
        $where = [
            'status'=>1,
            'key'=>$key,
        ];
        return self::query()->where($where)->value('value');
    }

}
